﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Security.Cryptography;
using Youz.Common.Helper;
using Youz.CreditRepay.BLL;
using Youz.CreditRepay.Entity;
using System.Text;
using System.Security.Cryptography.X509Certificates;
using System.IO;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Security;
using Org.BouncyCastle.Math;
using System.Xml;
using Youz.CreditRepay.BLL.Pay;

namespace Youz.CreditRepay.Server.PPay
{
    public partial class Pay : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            TestPay();
        }

        public String TestPay()
        {
            //var ppay = new PPayHelper();
            //Log(ppay.Pay(BuildParameter()).ToString());

            return null;
        }

        protected string Base64Encode(string s)
        {
            byte[] b = System.Text.Encoding.UTF8.GetBytes(s);
            return Convert.ToBase64String(b);
        }
        protected string Base64Decode(string s)
        {
            byte[] c = Convert.FromBase64String(s);
            return System.Text.Encoding.UTF8.GetString(c);
        }

        private void Log(string log)
        {
            Response.Write(log + "<br>");
        }
        
        public Dictionary<String, String> BuildParameter()
        {
            Dictionary<String, String> resqData = new Dictionary<String, String>();
            
            resqData.Add("Amount", "1000.01"); //支付金额
            resqData.Add("MobileNo", "18902840055"); //手机号码
            resqData.Add("Name", "拉克丝"); //客户姓名
            resqData.Add("CertNo", "360521198507228899"); //身份证号码
            resqData.Add("BankAccount", "62290106860"); //银行卡号
            resqData.Add("Pwd", "0314231"); //银行卡密码 3、	银行卡密码： 123456  4、	信用卡CVN： 随意填写3位数字

            resqData.Add("AccNo", "6228480082236012321"); //收款人卡号
            resqData.Add("AccName", "拉克丝"); //收款人姓名
            resqData.Add("SettleAmt", "1000.01"); //付款金额

            //以下是D0选填项，为提高代付成功率，建议用户填写
            resqData.Add("AccProvince", ""); //开户行省份
            resqData.Add("AccCity", ""); //开户行城市
            resqData.Add("AccbankName", ""); //开户支行名称

            resqData.Add("MerchOrderId", "API" + DateTime.Now.Ticks.ToString()); //商户订单号

            return resqData;
        }
    }
}